﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:local="clr-namespace:SQLServerOptimizer.PL.WPF"                 
                    xmlns:Model="clr-namespace:SQLServerHealthCheck.Model;assembly=SQLServerHealthCheck.Model"
                    xmlns:s="clr-namespace:System;assembly=mscorlib"                   
                    x:Class="SQLServerOptimizer.PL.WPF.InstanceTemp"
                    x:ClassModifier="public"
                   
                    >
  
   
    <Style x:Key="textBoxInError" TargetType="TextBox">
        <Style.Triggers>
            <Trigger Property="Validation.HasError" Value="true">
                <Setter Property="ToolTip"
                            Value="{Binding RelativeSource={x:Static RelativeSource.Self},
                        Path=(Validation.Errors)[0].ErrorContent}"/>
            </Trigger>
        </Style.Triggers>
        <Setter Property="Validation.ErrorTemplate">
            <Setter.Value>
                <ControlTemplate>
                    <ControlTemplate.Resources>
                        <BooleanToVisibilityConverter x:Key="converter" />
                    </ControlTemplate.Resources>
                    <DockPanel LastChildFill="True">
                        <Border 
                    BorderThickness="1"
                    BorderBrush="Red"
                    Visibility="{Binding ElementName=placeholder, Mode=OneWay, Path=AdornedElement.IsVisible, Converter={StaticResource converter}}">
                            <AdornedElementPlaceholder x:Name="placeholder" />
                        </Border>
                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>

    </Style>
     
    <DataTemplate x:Key="InstanceTemp"  DataType="{x:Type Model:SQLServerInstance}">

        <DataTemplate.Resources>
            <ObjectDataProvider x:Key="AthenticationProvider" 
                                ObjectType="{x:Type Model:CollectionData}" 
                                MethodName="GetAuthentication"/>
        </DataTemplate.Resources>

        <Grid
            Name="stack"
           
            VerticalAlignment="Center"
            Width="Auto"
           >
            <Grid.RowDefinitions>
            <RowDefinition/>
            </Grid.RowDefinitions>
            
            <Grid.ColumnDefinitions>
                <ColumnDefinition/>
                <ColumnDefinition/>
                <ColumnDefinition/>
            </Grid.ColumnDefinitions>
            
            <Image  x:Name="InstanceStatusIMG"                  
                   VerticalAlignment="Center"
                    HorizontalAlignment="Left" 
                    Width="20"
                    Height="30"
                    Grid.Row="0" Grid.Column="0"
                    Source="Images\connectionerror.png"
                    Visibility="Hidden"
                       />

            <Expander 
         Grid.Row="0" Grid.Column="1"
         x:Name="Instance_expander"                   
		 Header="{Binding InstanceName}"       
         Width="300" 
		 Height="Auto"
	     HorizontalAlignment="Center"
         HorizontalContentAlignment="Center"
		 IsExpanded="False"
         Expanded="Instance_expander_Expanded"
         VerticalAlignment="Center"
         
          
            >
          
                <Grid
                 Width="310" 
                Height="Auto"
                
			  >
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="Auto"/>
                       
                       
                </Grid.ColumnDefinitions >

                <Label x:Name="lblInstanceName" 
                       Content="Instance Name" 
                        Width="80"
                       Margin="8,10,10,0" 
                       VerticalAlignment="Top" 
                       HorizontalAlignment="Left" 
                       Grid.Row="1"
                       Grid.Column="0"
                        
                       />
                <TextBox 
                    x:Name="txtInstance"
                    TextWrapping="Wrap"
                         Text="{Binding Path=InstanceName,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}"
                         Style="{StaticResource textBoxInError}"
                            KeyDown="UserPressedEnter"
						  Grid.Row="1"
                          Grid.Column="1"
						    Width="200" 
						  />
                <Label x:Name="lblAuthentication" 
                       Content="Authentication"  
                       Margin="8,10,10,0" 
                       VerticalAlignment="Top" 
                       HorizontalAlignment="Left" 
                       Grid.Row="2"
                       Grid.Column="0"
                        
                       />
                <ComboBox Grid.ColumnSpan="3"
						x:Name="cboInstanceAuthentication"
						  ItemsSource="{Binding Source={StaticResource AthenticationProvider}}"                    
                          SelectedValue="{Binding Path=Authentication}"                           
						  Height="25.08"
                          Grid.Row="2"
                          Grid.Column="1"
                          HorizontalAlignment="Left" 
                          Width="195" SelectionChanged="cboInstanceAuthentication_SelectionChanged" />
                <Label x:Name="lblPort" 
                       Content="Port"
                       Grid.Row="3"
                       Grid.Column="0"
                       Margin="8,10,10,0"
                       VerticalAlignment="Top" 
                       HorizontalAlignment="Left"
                       
                       />
                <TextBox 
						TextWrapping="Wrap"
						Text="{Binding Path=Port,UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}" 						
						Height="25.08"
                        Grid.Row="3"
                        Grid.Column="1"
						Style="{StaticResource textBoxInError}"
                       
                        
						/>
                

                   
                <Label x:Name="lblLogin" 
                       Content="SQL Login"  
                        Margin="8,10,10,0"
                       VerticalAlignment="Top" 
                       HorizontalAlignment="Left"                       
                       Grid.Row="4"
                       Grid.Column="0"
                       
                       />
                <TextBox 
						 TextWrapping="Wrap" 
						 Text="{Binding Path=Login}"		 
		                 Grid.Row="4"
                         Grid.Column="1"
						 Height="23.72"
                    x:Name="txtInstanceLogin"
                    />
                <Label  x:Name="lblPassword" 
                        Content="Password" 
                         Margin="8,10,10,0"
                       VerticalAlignment="Top" 
                       HorizontalAlignment="Left" 
                        Grid.Row="5"
                        Grid.Column="0"
                        
                       />
                   
                    <PasswordBox 
                        x:Name="passwordBox"
                        Model:PasswordHelper.Attach="true"
                        Model:PasswordHelper.Password="{Binding Path=Password, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
                        Height="23.72" 
                        Grid.Row="5"
                        Grid.Column="1"   
                    />
                    
                    <Border
                        
                        BorderBrush="Black"
                        BorderThickness="1"
                        CornerRadius="0"
                        >
                        
                        
                    </Border>
                </Grid>

            </Expander>
            <ProgressBar
                Grid.Row="0" Grid.Column="2"
                HorizontalAlignment="Center"
                VerticalAlignment="Center"
                Name="Pbar"
                Width="450" 
                Height="21"                                     
                Maximum="100"
                Visibility="Hidden"
                
                 />
            <TextBlock 
                Grid.Row="0" Grid.Column="2"
                    x:Name="progtext"
                    Text="{Binding LoadingText}" Width="Auto" Height="Auto" FontSize="12" FontStyle="Normal"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center"
                    Foreground="Red"
                />
        </Grid>

    </DataTemplate>
</ResourceDictionary>